<?
session_start();
function DoLogin($email, $password)
{
	$sql = "
		SELECT U.id, password, FirstName, LastName
		FROM 2011_Users U
			Join 2011_ContactMethods CM On U.id=CM.User_Id
		WHERE CM.`Value` = '$email'
		";
	$conn = getConnection();
	$result = $conn->query($sql);
	//echo $conn->error;
	$rs = $result->fetch_assoc();
	$conn->close();
	if($rs['password'] == $password)
	{
		$_SESSION['UserId'] = $rs['id'];
		$_SESSION['UserEmail'] = $email;
		$_SESSION['UserName'] = $rs['FirstName'] . ' ' . $rs['LastName'];
	}
}
function IsLoggedIn()
{
	return isset($_SESSION['UserId']);
}
function GetUserName()
{
	return $_SESSION['UserName'];
}
function GetUserId()
{
	return $_SESSION['UserId'];
}
function GetUserEmail()
{
	return $_SESSION['UserEmail'];
}
function DoLogOut()
{
	session_destroy();
}
